package com.ffx.service.impl;


import com.ffx.mapper.ClassesMapper;
import com.ffx.mapper.StudentMapper;
import com.ffx.pojo.Student;
import com.ffx.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @outhor fufeixiang
 * @date 2021-11-09
 */
@Service
public class StudentServiceImpl implements StudentService {
    //依赖注入
    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private ClassesMapper classesMapper;

    //查找所有学生
    @Override
    public List<Student> findAll() {
        List<Student> studentList = studentMapper.selectByExample(null);
        //为学生添加班级名称
        for (Student student : studentList){
            student.setCname(classesMapper.selectByPrimaryKey(student.getCid()).getCname());
        }
        return studentList;
    }
}
